import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_layout/base/index.dart';
import 'package:flutter_layout/data/event_task_bean.dart';

class EventBusPage extends StatefulWidget {
  const EventBusPage({Key? key}) : super(key: key);

  @override
  _EventBusPageState createState() => _EventBusPageState();
}

class _EventBusPageState extends State<EventBusPage> {
  StreamSubscription<EventTaskBean>? subscription;
  String? _title;

  @override
  Widget build(BuildContext context) {
    logger.e("-----build");
    subscription ??= behaviorBus.on<EventTaskBean>().listen((event) {
      var map = event.value as Map<String, dynamic>;
      setState(() {
        _title = map['id'].toString();
        showToast(_title!);
      });
    });

    return Scaffold(
      appBar: AppBar(
        title: Text(_title ?? ""),
      ),
      body: Container(),
    );
  }
}
